﻿#ifndef FORMMVB_H
#define FORMMVB_H

#include <QStandardItemModel>
#include <QWidget>
#include<qvector.h>
#include<QDateTime>


#include"Tool/qxlsxhelper.h"
#include"Common/protocalFormat.h"
#include"Common/TestResult.h"
#include"Thread/mvbtestthread.h"
#include"Tool/websocketclient.h"
#include "formtcpfileclient.h"
namespace Ui {
class FormMvb;
}

class FormMvb : public QWidget
{
    Q_OBJECT

    enum WorkStatus
    {
        START=0,
        PAUSE,
        STOP
    };

public:
    explicit FormMvb(QWidget *parent = nullptr);
    ~FormMvb();
    void OnReceiveOCRImg(QByteArray byteArray);
private:
    void LoadProtocal();
    void start();
    void stop();
    void Pause();
    void Export();
    void init();
    void connectAllSlots();
    void ClearTableViewTestResult();

signals:
    void SendImgRect(const cv::Mat& mat);
    void SendLogMsg(const QString& logMsg,int ntype=0);
private slots:
    void on_btn_snap_clicked();
    void OnThreadSnap();
    void OnThreadExit();
    void ShowTestResuult(const QVariant& testResult);
    void on_btnTest_clicked();
    void on_btn_configMVB_clicked();


private:
    Ui::FormMvb *ui;
    qxlsxHelper _xlsxHelper;
    ProtocalData _protocalData;
    QStandardItemModel* _tableViewmodel=nullptr;
    QStandardItemModel* _ProtocaltableViewmodel=nullptr;
    MVBTestThread _MvbTestthread;
    TestResult _testResult;
    WebsocketClient* _websocketClient = nullptr;
    bool _bSnapOnly=false;
    int _nShowLine=5;
    WorkStatus _workStatus;
    FormTcpFileClient* _FileclientForm = nullptr;

};

#endif // FORMMVB_H
